﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Chrysalis;
using Microsoft.Phone.Tasks;
using Chrysalis.Services;
using Chrysalis.Composition;

namespace ChrysalisTest.ViewModels
{
    public class ChoosersViewModel : ViewModelBase
    {
        // *** Constructors ***

        public ChoosersViewModel()
        {
            if (ChrysalisService.Current != null)
                ChrysalisService.Current.SatisfyImports(this);
        }

        // *** Properties ***

        [ChrysalisImport]
        public IChooserExecutionService ChooserExecutionService
        {
            get;
            set;
        }

        // *** Methods ***

        public void ChoosePhoneNumber()
        {
            PhoneNumberChooserTask task = new PhoneNumberChooserTask();

            ChooserExecutionService.ExecuteChooser(task, OnChoosePhoneNumberCompleted);
        }

        public void SavePhoneNumber()
        {
            SavePhoneNumberTask task = new SavePhoneNumberTask();
            task.PhoneNumber = "1234";

            ChooserExecutionService.ExecuteChooser(task, OnSavePhoneNumberCompleted);
        }

        public void TakePhoto()
        {
            CameraCaptureTask task = new CameraCaptureTask();

            ChooserExecutionService.ExecuteChooser(task, OnTakePhotoCompleted);
        }

        public void OnChoosePhoneNumberCompleted(PhoneNumberResult e)
        {
            MessageBox.Show(string.Format("PhoneNumberChooserTask : {0}", e.PhoneNumber));
        }

        public void OnSavePhoneNumberCompleted(TaskEventArgs e)
        {
            MessageBox.Show(string.Format("SavePhoneNumberTask Result : {0}", e.TaskResult));
        }

        public void OnTakePhotoCompleted(PhotoResult e)
        {
            MessageBox.Show(string.Format("Photo Result : {0}", e.TaskResult));
        }
    }
}
